import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Axios from "axios";
import qs from "qs";
import APlayer from "@moefe/vue-aplayer";

Vue.use(APlayer, {
  defaultCover: "https://github.com/u3u.png", // 设置播放器默认封面图片
  productionTip: true // 是否在控制台输出版本信息
});

import VueParticles from "vue-particles";
Vue.use(VueParticles);
// 导入全局样式文件
import "./assets/css/global.css";
import "./plugins/element.js";

Vue.config.productionTip = false;

//Axios.defaults.publicPath = 'http://localhost:8888/'
Axios.defaults.baseURL = "http://127.0.0.1:8888/";
//Axios.defaults.headers.common['Authorization'] = window.sessionStorage.getItem("token");
//Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
// 请求拦截器
Axios.interceptors.request.use(
  function(config) {
    // if(config.method === 'post'){
    //   config.data = qs.stringify(config.data)
    // }
    // 对请求数据做点什么
    // console.log(config);
    config.headers.Authorization = window.sessionStorage.getItem("token");
    //config.headers.Accept = "application/x-www-form-urlencoded";
    console.log(config);
    return config;
  },
  function(error) {
    // 对请求错误做点什么
    console.log(error);
    return Promise.reject(error);
  }
);
Vue.prototype.$http = Axios;
Vue.prototype.$qs = qs;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
